﻿using Rosetta.AddIns.Compression;
using Rosetta.Composition;
using Rosetta.Default;

namespace Rosetta.Viewer
{
    public partial class MainWindow
    {
        #region Fields

        private readonly IContainer container;
        private readonly Template template;

        #endregion

        #region Constructors

        public MainWindow()
        {
            InitializeComponent();

            container = new Container();
            container.LoadAssembly(typeof(Container).Assembly);
            container.LoadAssembly(typeof(ZipFileConverter).Assembly);

            template = new Template(container);

            // TEMP: Hardcoded
            var startNode = template.AddInputNode("Rosetta.Default.AddIns.Text.StringInputter, Rosetta.Default", "GetInt32");
            startNode.Description = "start";
            var countNode = template.AddInputNode("Rosetta.Default.AddIns.Text.StringInputter, Rosetta.Default", "GetInt32");
            countNode.Description = "count";

            var rangeNode = startNode.AddChild("Rosetta.Default.AddIns.RangeConverter, Rosetta.Default", "GetInt32Range", 0).EndPoint;
            countNode.AddChild(rangeNode, 1);

            rangeNode.AddChild("Rosetta.Default.AddIns.NullOutputter, Rosetta.Default", "Output", 0);

            var rangeNode2 = startNode.AddChild("Rosetta.Default.AddIns.RangeConverter, Rosetta.Default", "GetInt32Range", 0).EndPoint;
            countNode.AddChild(rangeNode2, 1);

            startNode.AddChild("Rosetta.Default.AddIns.RangeConverter, Rosetta.Default", "GetInt32Range", 0);

            PART_viewer.Template = template;
        }

        #endregion
    }
}